package com.example.demo.controller;

import com.example.demo.constants.Constants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/producer")
@RestController
public class ProducerController {

     @Autowired
    private RabbitTemplate rabbitTemplate;
//     rabbitTemplate封装了RabbitMQ交互的底层细节,可以用于消息发送和接收
     @RequestMapping("/work")
    public String work(){
         rabbitTemplate.convertAndSend("", Constants.WORK_QUEUE,"hello,spring amqp:work...");
         return "发送成功";
    }
}
